<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>分类列表</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="/static/css/font.css">
		<link rel="stylesheet" href="/static/css/xadmin.css">
		<script src="/static/js/jquery.min.js" charset="utf-8"></script>
        <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/static/js/xadmin.js"></script>
        <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="JavaScript:#">分类管理</a>
            <a><cite>分类列表</cite></a>
          </span>
          <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            <button class="layui-btn" onclick="xadmin.open('添加分类','{:url('admin/Category/addcategory')}',800,500)"><i class="layui-icon"></i>添加</button>
                        </div>
						<div class="layui-card-body ">
							<table class="layui-table layui-form">
                              <thead>
                                <tr>
                                  <th>序号</th>
                                  <th>分类名称</th>
                                  <th>状态</th>
                                  <th>操作</th>
                              </thead>
                              <tbody>
								{volist name="catlist" id="vo"}
                                <tr>
                                  <td>{$vo.category_id}</td>
                                  <td>{$vo.category_name}</td>
                                  <td>{if condition="$vo.is_show eq 0"}正常{else /}关闭{/if}</td>
                                  <td class="td-manage">
										<button class='layui-btn' onclick="xadmin.open('修改分类','{:url('admin/Category/editcategory',['id'=>$vo.category_id])}',800,500)">修改</button>
										<button class='layui-btn delAdmin' rid="{$vo.category_id}">删除</button>
                                  </td>
                                </tr>
								{volist name="$vo.fid" id="v"}
									<tr>
									  <td>{$v.category_id}</td>
									  <td>|----{$v.category_name}</td>
									  <td>{if condition="$v.is_show eq 0"}正常{else /}关闭{/if}</td>
									  <td class="td-manage">
											<button class='layui-btn' onclick="xadmin.open('修改分类','{:url('admin/Category/editcategory',['id'=>$v.category_id])}',800,500)">修改</button>
											<button class='layui-btn delAdmin' rid="{$v.category_id}">删除</button>
									  </td>
									</tr>
								{/volist}
								{/volist}
                              </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div> 
		<script>
			 //删除请假
			$('body').on('click', '.delAdmin', function(){
				var get_this = $(this);
				parent.layer.confirm('你确定要删除该条信息吗?', function(){
					var params = {};
					params.id = get_this.attr('rid');
					$.ajax({
						type: "POST",
						url: "/admin/category/delcategory.html",
						cache: false, //禁用缓存
						data: params, //传入组装的参数
						dataType: "json",
						success: function (result) {
							if(result.code==10001){
								location.reload();
								parent.layer.msg('操作成功', {icon: 1});
							}else{
								parent.layer.msg(result.msg, {icon: 5});
							}
						},
						error:function () {
							parent.layer.msg('网络错误', {icon: 5});
						}
					})
				});
			});
		</script>
    </body>
</html>